package com.yang.newCustomersTransferBackProcess.dao;

import com.yang.newCustomersTransferBackProcess.pojo.NewCustomersTransferBack;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface NewCustomersTransferBackDao extends JpaRepository<NewCustomersTransferBack, Integer>, JpaSpecificationExecutor<NewCustomersTransferBack> {

    @Query(value = "select * from new_customers_transfer_back where customer_id = ?1", nativeQuery = true)
    NewCustomersTransferBack findNewCustomersTransferBack(int customerId);

    @Query(value = "select count(id) from new_customers_transfer_back where customer_id = ?1", nativeQuery = true)
    Integer queryNewCustomersTransferBackCount(int customerId);

//    @Query(value = "select count(nctb.id) from new_customers_transfer_back nctb inner join adviser a on nctb.adviser_id = a.id where nctb.customer_id = ?1 and a.team_id like ?2 ", nativeQuery = true)
//    Integer queryNewCustomersTransferBackCount(int customerId, int teamId);

    @Query(value = "select * from new_customers_transfer_back where id = ?1", nativeQuery = true)
    NewCustomersTransferBack queryNewCustomersTransferBackById(int id);
}
